package day08;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Demo11 {

	public static void main(String[] args) {
		String from="abc/hh.txt";
		String to="abc/hh2.txt";
		
		copy(from,to);
		
		
		
		
		

	}

	public static void copy(String from, String to) {
		FileInputStream in=null;
		FileOutputStream out=null;
		try {
			in = new FileInputStream(from);
			out = new FileOutputStream(to);

			byte[] buf = new byte[1024];
			int n;
			while ((n = in.read(buf)) != -1) {
				out.write(buf, 0, n);
			}

		} catch (FileNotFoundException e) {
			System.out.println("源文件不存在！"+from);

		} catch (IOException e) {

		} finally {

			try {
				if(in!=null) in.close();
				if(out!=null) out.close();
			} catch (IOException e) {

			}

		}

	}

}
